package com.noahplat.oufu.controller;

import com.noahplat.oufu.service.RecvDataHandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 作者：李景星
 * 描述：欧孚B2315+数据接收解析接口
 * 时间：2021-02-23
 */
@RestController
@RequestMapping("/api/oufu/recv")
public class RecvController {
    @Autowired
    private RecvDataHandService recvDataHandService;

    @PostMapping("/handler")
    public void recvDataHand(@RequestBody String msg){//临时测试通信方法，真正解析需要放在service
        recvDataHandService.recvDataHand(msg);
    }

    /**
     * 判断围栏进出报警接口
     * @param imei
     * @param loca
     * @param site
     */
    @PreAuthorize("hasAuthority('noahplat-service-oufu:RecvController:poFence')")
    @PostMapping("/poFence")
    public void poFence(String imei, String loca, String site){
        recvDataHandService.poFence(imei,loca,site);
    }
}
